<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>使用toString()方法输出16进制8进制2进制</title>
</head>

<body>
    <script>
        var myNumber = 128;
        document.write(myNumber + ' 十进制<br>');
        document.write(myNumber.toString(16) + ' 十六进制<br>');
        document.write(myNumber.toString(8) + ' 八进制<br>');
        document.write(myNumber.toString(2) + ' 二进制<br>');
    </script>
</body>

</html>